﻿using System.ServiceModel;
using System.ServiceModel.Web;
using System.ServiceModel.Channels;
using System.IO;

namespace MyWcfRestLib.Files
{
    [ServiceContract]
    public interface IFileTransfer
    {
        [OperationContract]
        [WebGet(UriTemplate = "get_service_info", ResponseFormat = WebMessageFormat.Json)]
        ServiceInfo GetServiceInfoApi();

        [OperationContract]
        [WebGet(UriTemplate = "get_devices", ResponseFormat = WebMessageFormat.Json)]
        DeviceInfo[] GetDevicesApi();

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "create_device", ResponseFormat = WebMessageFormat.Json)]
        DeviceInfo CreateDeviceApi(Stream stream);

        [OperationContract]
        [WebGet(UriTemplate = "file?root={deviceRoot}&path={path}")]
        Stream DownloadApi(string deviceRoot, string path);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "file?root={deviceRoot}&path={path}", ResponseFormat = WebMessageFormat.Json)]
        void UploadApi(Stream stream, string deviceRoot, string path);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "chunked_upload?upload_id={uploadId}&offset={offset}", ResponseFormat = WebMessageFormat.Json)]
        ChunkUploadInfo ChunkedUploadApi(Stream stream, string uploadId, int offset);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "commit_chunked_upload", ResponseFormat = WebMessageFormat.Json)]
        MetadataInfo CommitChunkedUploadApi(Stream stream);

        [OperationContract]
        [WebGet(UriTemplate = "metadata?root={deviceRoot}&path={path}", ResponseFormat = WebMessageFormat.Json)]
        MetadataInfo GetMetadataApi(string deviceRoot, string path);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "fileops/copy", ResponseFormat = WebMessageFormat.Json)]
        MetadataInfo CopyFileApi(Stream stream);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "fileops/delete", ResponseFormat = WebMessageFormat.Json)]
        MetadataInfo DeleteFileApi(Stream stream);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "fileops/move", ResponseFormat = WebMessageFormat.Json)]
        MetadataInfo MoveFileApi(Stream stream);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "fileops/create_folder", ResponseFormat = WebMessageFormat.Json)]
        MetadataInfo CreateFolderApi(Stream stream);

    }
}
